package mdm.com.sap;

import java.util.Iterator;

import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.JCoField;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoParameterList;
import com.sap.conn.jco.JCoStructure;
import com.sap.conn.jco.JCoTable;

public class GetPOInfo {

    
    public static void Get_POInfo(String PDN) {
        try {
            JCoFunction function = RfcManager.getFunction("ZBAPI_PO_GETDETAIL_GR_V1");
            JCoParameterList importParam = function.getImportParameterList();
            importParam.setValue("I_EBELN", PDN);
            function.execute(RfcManager.getDestination());
            
//            JCoStructure JcoReturn = function.getExportParameterList().getStructure("I_RETURN");
            JCoTable dt_POHeader = function.getTableParameterList().getTable("ZEKKO");
//            JCoTable dt_PODetail = function.getTableParameterList().getTable("ZEKPO");
//            JCoTable dt_POOther = function.getTableParameterList().getTable("ZBATCH_CLASS");
            Iterator<JCoField> jcotable=function.getTableParameterList().iterator();
            while(jcotable.hasNext()) {
                JCoField next = jcotable.next();
                if(next!=null) {
                    System.out.println("=====tables Name===="+next.getName());
                }
            }
            Iterator<JCoField> jco=dt_POHeader.iterator();
            while(jco.hasNext()) {
                JCoField next = jco.next();
                if(next!=null) {
                    System.out.println("key===="+next.getName());
                }
            }
//            for (int j = 0; j < dt_POHeader.getNumRows(); j++) {
//                dt_POHeader.setRow(j);
//                System.out.println("=====EBELN===="+dt_POHeader.getString("EBELN"));
//            }
        } catch (JCoException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
